﻿using DevelopAssistant.Service;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DevelopAssistant.Core
{
    public partial class AboutForm : ICSharpCode.WinFormsUI.Forms.BaseForm
    {
        public AboutForm()
        {
            InitializeComponent();
        }

        public AboutForm(MainForm OwnerForm)
            : this()
        {
            this.lblproductName.Text = OwnerForm.ProductName;
            this.lblproductVersion.Text = OwnerForm.ProductVersion;          
            this.XTheme = AppSettings.WindowTheme; //OwnerForm.XTheme;
        }

        private string Trim(string input)
        {
            string result = string.Empty;
            if (!string.IsNullOrEmpty(input))
            {
                result = input.Trim().TrimEnd('\\');
            }
            return result;
        }

        private void AboutForm_Load(object sender, EventArgs e)
        {
            
        }

        private void lblproductVersion_Click(object sender, EventArgs e)
        {
            string application_start_path = Trim(AppDomain.CurrentDomain.BaseDirectory);
            if (System.IO.File.Exists(string.Format("{0}\\Autoupgrade.EXE", application_start_path)))
            {
                System.Diagnostics.Process.Start(string.Format("{0}\\Autoupgrade.EXE", application_start_path));
                try
                {
                    System.Threading.Thread.Sleep(100);
                    Application.Exit();
                }
                catch (Exception ex)
                {
                    DevelopAssistant.Common.NLogger.WriteToLine(ex.Message, "错误", DateTime.Now, ex.Source, ex.StackTrace);
                    Environment.Exit(0);
                }
            }
        }

        
    }
}
